<?php

function stumbleinfo_request($name, $default=null)
{
	if (!isset($_REQUEST[$name])) return $default;
	if (get_magic_quotes_gpc()) return stumbleinfo_stripslashes($_REQUEST[$name]);
	else return $_REQUEST[$name];
}

function stumbleinfo_stripslashes($value)
{
	$value = is_array($value) ? array_map('stumbleinfo_stripslashes', $value) : stripslashes($value);
	return $value;
}

function stumbleinfo_field_text($name, $label='', $tips='', $attrs='')
{
  global $options;
  if (strpos($attrs, 'size') === false) $attrs .= 'size="30"';
  echo '<tr><td class="label">';
  echo '<label for="options[' . $name . ']">' . $label . '</label></td>';
  echo '<td><input type="text" ' . $attrs . ' name="options[' . $name . ']" value="' .
    htmlspecialchars($options[$name]) . '"/>';
  echo ' ' . $tips;
  echo '</td></tr>';
}


function stumbleinfo_field_checkbox($name, $label='', $tips='', $attrs='')
{
  global $options;
  echo '<tr><td class="label">';
  echo '<label for="options[' . $name . ']">' . $label . '</label></td>';
  echo '<td><input type="checkbox" ' . $attrs . ' name="options[' . $name . ']" value="1" ' .
    ($options[$name]!= null?'checked':'') . '/>';
  echo ' ' . $tips;
  echo '</td></tr>';
}

if (isset($_POST['Submit']))
{
  $options = stumbleinfo_request('options');
  update_option('stumbleinfo', $options);
}
else
{
    $options = get_option('stumbleinfo');
}

?>

<div class="wrap">
<form method="post">

<h2>Stumbleinfo Icon</h2>

<h2>Every link</h2>

<table>
	<? stumbleinfo_field_checkbox('stumbleinfo_showicon', 'Show Icon', '');  ?>
</table>

<table>
	<? stumbleinfo_field_text('stumbleinfo_beforesu', 'Text before the indicator', ''); ?>
	<? stumbleinfo_field_text('stumbleinfo_aftersu', 'Text after the indicator', ''); ?>
</table>

<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
</p>

</form>
</div>

